<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <title>房屋租赁系统</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/module/admin.css?v=318"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/libs/layui/css/font-awesome.min.css" media="all">
    <link href="${pageContext.request.contextPath}/static/images/houserent.ico" rel="icon">
</head>
<body class="layui-layout-body close-footer theme-pink">
<div class="layui-layout layui-layout-admin">
    <!-- 头部 -->
    <div class="layui-header">
        <div class="layui-logo">
            <a href="${pageContext.request.contextPath}/jsp/main.jsp">
                <img src="${pageContext.request.contextPath}/static/images/logo.png" style="height: 55px"/>
                <cite>&nbsp;房屋租赁系统</cite>
            </a>
        </div>
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item" lay-unselect>
                <a ew-event="flexible" title="侧边伸缩"><i class="layui-icon layui-icon-shrink-right"></i></a>
            </li>
            <li class="layui-nav-item" lay-unselect>
                <a ew-event="refresh" title="刷新"><i class="layui-icon layui-icon-refresh-3"></i></a>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide-xs" lay-unselect>
                <a ew-event="fullScreen" title="全屏"><i class="layui-icon layui-icon-screen-full"></i></a>
            </li>
            <li class="layui-nav-item" lay-unselect>
                <a>
                    <img src="/images/userimgs/${user.uuidName==null?"1.png":user.uuidName}" class="layui-nav-img">
                    <cite>${user.userName}</cite>
                </a>
                <dl class="layui-nav-child">
                    <dd lay-unselect><a ew-href="${pageContext.request.contextPath}/backjsp/userpwd.jsp">修改密码</a></dd>
                    <hr>
                    <dd lay-unselect><a ew-event="logout" data-url="${pageContext.request.contextPath}/backjsp/loginback.jsp">退出</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-unselect style="visibility: hidden;">
                <a ew-event="theme" title="主题"><i class="layui-icon layui-icon-more-vertical"></i></a>
            </li>
        </ul>
    </div>

    <!-- 侧边栏 -->
    <div class="layui-side">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree arrow2" lay-filter="admin-side-nav" style="margin: 15px 0;">
            </ul>
        </div>
    </div>

    <!-- 主体部分 -->
    <div class="layui-body"></div>
</div>

<!-- 加载动画 -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>

<!-- 侧边栏渲染模板 -->
<script id="sideNav" type="text/html">
    {{#  layui.each(d, function(index, item){ }}
    <li class="layui-nav-item">
        <a lay-href="{{item.url}}"><i class="{{item.icon}}"></i>&emsp;<cite>{{ item.name }}</cite></a>
        {{# if(item.subMenus&&item.subMenus.length>0){ getSubMenus(item.subMenus); } }}
    </li>
    {{#  }); }}
    {{# function getSubMenus(subMenus){ }}
    <dl class="layui-nav-child">
        {{# layui.each(subMenus, function(index, subItem){ }}
        <dd>
            <a lay-href="{{ subItem.url }}">{{ subItem.name }}</a>
            {{# if(subItem.subMenus&&subItem.subMenus.length>0){ getSubMenus(subItem.subMenus); } }}
        </dd>
        {{# }); }}
    </dl>
    {{# } }}
</script>

<script type="text/javascript" src="${pageContext.request.contextPath}/static/libs/layui/layui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/common.js?v=318"></script>
<script>
    layui.use(['layer', 'element', 'admin', 'index', 'laytpl', 'element'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var admin = layui.admin;
        var index = layui.index;
        var laytpl = layui.laytpl;
        var element = layui.element;

        // 默认加载主页
        index.loadHome({
            menuPath: '${pageContext.request.contextPath}/backjsp/welcome.jsp',
            menuName: '<i class="layui-icon layui-icon-home"></i>',
            loadSetting: false
        });

        // ajax渲染侧边栏
        $.get('${pageContext.request.contextPath}/user/menu', function (res) {
            laytpl(sideNav.innerHTML).render(res.data, function (html) {
                $('*[lay-filter=admin-side-nav]').html(html);
                element.render('nav');
            });
        }, 'json');

    });
</script>
</body>
</html>